home *** CD-ROM | disk | FTP | other *** search
- ///////////////////////////////////////////////////////////////
- //
- // Module : HOUSE00.PRG
- //
- // Created by SUMMER'93 (c) on Fri Nov 26 14:50:39 1993
- //
- ///////////////////////////////////////////////////////////////
- #include "snj.ch"
- // The following statics were declared 'PUBLIC' in the S87 code
- // OR were private and inherited by called functions
- // If they are used outside this module there will be a set/get
- // function with the same name as the var in this module
- static DBREC, DBNAME
- procedure HOUSEMAIN
- // Calls: QBLAYOUT QBBOX QBMENU CTEDIT BODARCH BODREST
- // Called By: BODYWORK
- // H O U S E 0 0
- // Main controlling routine for Housekeeping
- local HSCOM, OLDMLIN, RTITLE, RCHOIX
-
- QBCHOICE( 1 )
- do while .t.
- // Last change: MIB 26 Oct 93 5:51 pm
-
- close database
- do QBLAYOUT with "Housekeeping"
- do QBBOX with 40
- do QBMENU with "HOUSEKE", 40
- RTITLE := QBPROC()
- RCHOIX := QBCHOICE()
- do case
- case RCHOIX = 0 .or. RCHOIX = 5
- exit
- case RCHOIX = 1
- do QBLAYOUT with RTITLE
- do CTEDIT with 5, 19, 15, 1
- case RCHOIX = 2
- do QBLAYOUT with RTITLE
- do QBBOX with 40
- case RCHOIX = 3
- do QBLAYOUT with RTITLE
- do QBBOX with 40
- do BODARCH
- case RCHOIX = 4
- do QBLAYOUT with RTITLE
- do QBBOX with 40
- do BODREST
- endcase
- QBCHOICE( RCHOIX )
- enddo
- set softseek off
- return
-
- //******************************************************************
-
- procedure BODARCH
- // Calls: QB2DATES QBMESS QBYESNO DRIVEOK GETREC PUTREC QBWIPE QBCLMESS
- // Called By: HOUSEMAIN
- // B O D A R C H . P R G
- // Program to archive Invoices
- // The following locals have been declared by Summer'93
- // ADATE
- local status, D1, D2, ADATE
-
- status := 0
- D1 := D2 := ctod("" )
-
- select 0
- use PARTS index PARTINV alias PARTS
- select 0
- use INVOICE index INVDATE, INVNUM, INVCUST alias INVOICE
-
- // Method: Create structure on Disc a:
- ADATE := date( )
-
- @ 5, 26 say " First date: "
- @ 7, 26 say "Second date: "
- do QB2DATES with "Input Start and Finish dates", 5, 39, D1, 7, 39, D2
-
- set softseek on
- seek dtos( D1 )
- if eof( )
- do QBMESS with "No Invoices to be archived", COLFLASH() , 5
- return
- endif
-
- if QBYESNO( "OK to Continue?" ) = "N" .or. GETOUT()
- close database
- return
- endif
-
- do QBMESS with "Place a formatted floppy in drive A", COLHEAD() , 0
- if !DRIVEOK( )
- GETOUT( .f. )
- return
- endif
- do QBMESS with "Selecting Invoices", COLFLASH() , 0
-
-
- do QBMESS with "Archiving Invoices and Parts to Floppy", COLFLASH() , 0
-
- // Create Files on Floppy
- select INVOICE
- copy structure to A:INVOICE
- select PARTS
- copy structure to A:PARTS
- select 0
- use A:PARTS alias APARTS
- select 0
- use A:INVOICE alias ANVOICE
-
- go top
- select INVOICE
- set softseek on // Invoices
- seek dtos( D1 )
- do while INVOICE->DATEINV <= D2 .and. !eof( )
- GETREC( ) // Get the current record in the database
- select ANVOICE
- PUTREC( ) // Put it in the other
- MINVNO( ANVOICE->INVNO ) // Get a number from A drive
-
- set softseek off // Part by Invoice #
- select PARTS
- seek str( MINVNO() , 5 ) // Find in main file
- do while !eof( ).and. MINVNO() = PARTS->INVNO
- GETREC( )
- select APARTS
- PUTREC( )
- select PARTS
- do QBWIPE
- seek str( MINVNO() , 5 ) // Find in main file
- enddo
-
- set softseek on // Erase Invoice, Get next
- select INVOICE
- do QBWIPE
- seek dtos( D1 )
- enddo
-
- do QBCLMESS
- close database
- do QBMESS with "Remove floppy from drive A: and label it", COLHEAD() , 0
- wait
- set softseek off
-
- do QBCLMESS
- return
-
- //******************************************************************
- function GETREC
- // Calls:
- // Called By: BODARCH
- local NUMFLDS, T, I
-
- NUMFLDS := fcount( )
- DBREC := array( NUMFLDS )
- DBNAME := array( NUMFLDS )
-
- afields( DBNAME )
- for I := 1 to NUMFLDS
- T := DBNAME[ I ]
- DBREC[ I ] := &T
- next
-
- BLIMEMPAK( - 1 )
-
- return .t.
-
- //******************************************************************
- function PUTREC
- // Calls:
- // Called By: BODARCH
- local NUMFLDS, T, I
-
- NUMFLDS := fcount( )
-
- append blank
- afields( DBNAME )
- for I := 1 to NUMFLDS
- T := DBNAME[ I ]
- replace &T with DBREC[ I ]
- next
-
- BLIMEMPAK( - 1 )
-
- return .t.
-
- //******************************************************************
-
- procedure BODREST
- // Calls: QBYESNO QBMESS DRIVEOK
- // Called By: HOUSEMAIN
- // B O D R E S T
- local status
-
- status := 0
- select 0
- use INVOICE index INVNUM, INVDATE, INVCUST
- select 0
- use PARTS index PARTINV
-
- @ 5, 26 say "Restoring Invoices"
-
- if QBYESNO( "OK to Continue?" ) = "N"
- close database
- return
- endif
-
- do while .t.
- do QBMESS with "Place the Archive floppy in drive A", COLHEAD() , 0
- if !DRIVEOK( )
- GETOUT( .f. )
- return
- endif
- if file( "a:invoice.dbf" ).and. file( "a:parts.dbf" )
- do QBMESS with "Appending Invoices from Floppy", COLHEAD() , 0
- select INVOICE
- append from A:INVOICE
- select PARTS
- append from A:PARTS
- exit
- else
- do QBMESS with "Floppy does not contain correct files - try again", ;
- COLFLASH() , 5
- if QBYESNO( "OK to try again?" ) = "N"
- close database
- return
- endif
- endif
- enddo
- do QBMESS with "Reindexing Invoices", COLHEAD() , 0
- select INVOICE
- index on str( FIELD->INVNO , 5 )to INVNUM
- index on dtos( FIELD->DATEOUT ) + FIELD->CUSTTYPE to INVDATE
- index on FIELD->CUSTTYPE + dtos( FIELD->DATEOUT )to INVCUST
- index on upper( FIELD->OWNNAME )to INVNAME
-
- select PARTS
- index on str( FIELD->INVNO , 5 ) + str( FIELD->PLINENO , 2 )to PARTINV
-
- do QBMESS with "Remove floppy from drive A: ", COLHEAD() , 0
- wait
-
- close database
-
- return
-
- //******************************************************************
-
-
- //******************************************************************
- function DRIVEOK
- // Calls: ISDRIVE QBPROMPT
- // Called By: BODARCH BODREST
- // The following locals have been declared by Summer'93
- // ACTION
- local ACTION
- GETOUT( .f. )
- do while !ISDRIVE( "A" )
- ACTION := QBPROMPT( "Continue|Quit|", ;
- "Floppy is not ready - correct and continue or Quit", 1 )
- if ACTION <> 1
- GETOUT( .t. )
- exit
- endif
- enddo
-
- return !GETOUT()
- // End of file
-